package org.ezplatform.office.questionnaire.web.client;
/** 
* @author 作者: wujs
* @version 创建时间：2018年1月12日 上午8:41:57 
* 类说明 :问卷接口
*/

import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.ezplatform.core.common.WebUser;
import org.ezplatform.core.service.BaseService;
import org.ezplatform.core.web.controller.BaseController;
import org.ezplatform.core.web.util.WebUtils;
import org.ezplatform.dingisv.util.OperationResultDing;
import org.ezplatform.office.questionnaire.entity.Questionnaire;
import org.ezplatform.office.questionnaire.service.QuestionnaireAnswerStatusService;
import org.ezplatform.office.questionnaire.service.QuestionnaireService;
import org.ezplatform.office.questionnaire.util.QuestionnaireUtils;
import org.ezplatform.util.JsonUtils;
import org.ezplatform.util.RestClient;
import org.ezplatform.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/client/office/questionnaire")
public class QuestionnaireClientController extends BaseController<Questionnaire, String>{
	
	private final static Logger LOG = LoggerFactory.getLogger(QuestionnaireClientController.class);
	
	@Autowired
	private QuestionnaireService questionnaireService;
	
//	@Autowired
//	private DictDetailApiService dictDetailApiService;
	
	@Override
	protected BaseService<Questionnaire, String> getEntityService() {
        return questionnaireService;
    }
	
	@Autowired
	private QuestionnaireAnswerStatusService answerStatusService;
	
	@ApiOperation(value = "实体类是否存在", notes = "")
	@RequestMapping(value="/entityIsExist", method=RequestMethod.POST, produces={"application/json; charset=UTF-8"})
    @ResponseBody
	public Map<String, Object> entityIsExist(HttpServletRequest request) {
    	Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			WebUser user = WebUtils.getCurrentUser();
			String id = request.getParameter("id");
			Map<String,String> paramsMap = new HashMap<String,String>();
            paramsMap.put("id", id);
            RestClient restClient = new RestClient();
    		String configJson = restClient.post("/questionnaire/entityIsExist", user.getJwtToken(), paramsMap);
    		Map<String, Object> result = JsonUtils.readValue(configJson);

            resultMap.put("success", true);
            resultMap.put("content", result.get("message"));

		} catch (Exception e) {
			resultMap.put("success", false);
			resultMap.put("content", "");
		}
		return resultMap;
    }
	
	/**
     * 获取回退原因
     * @param request
     * @return
     */
    @RequestMapping(value="/getBackReason", method=RequestMethod.GET, produces={"application/json; charset=UTF-8"})
    @ResponseBody
    public OperationResultDing getBackReason(HttpServletRequest request) {
		String id = request.getParameter("id");
		WebUser user = WebUtils.getCurrentUser();
		String corpId = user.getCorpId();
		String token = user.getJwtToken();
		Map<String,String> map = new HashMap<String,String>();
		map.put("corpId", corpId);
		map.put("userId", user.getUserId());
		map.put("token", token);
		map.put("id", id);

		RestClient restClient = new RestClient();
		String configJson = restClient.get("/questionnaire/getBackReason", token, map);
		Map<String, Object> result = JsonUtils.readValue(configJson);
		return OperationResultDing.buildSuccessResult(result);
    }
	
    /**
     * 获取问卷列表
     * @param request
     * @return
     */
    @RequestMapping(value="/getDingQuesList", method=RequestMethod.GET, produces={"application/json; charset=UTF-8"})
    @ResponseBody
    public OperationResultDing getDingQuesList(HttpServletRequest request) {
		String page = request.getParameter("page");
		String pageSize = request.getParameter("pageSize");
		String search = request.getParameter("search");
		String quesType = request.getParameter("quesType");
		String quespublish = request.getParameter("quespublish");
		String startDate = request.getParameter("startDate");
		String endDate = request.getParameter("endDate");
		WebUser user = WebUtils.getCurrentUser();
		String corpId = user.getCorpId();
		String token = user.getJwtToken();
		//List<Map> page = questionnaireService.getQuesList(corpId,"",type);
		Map<String,String> map = new HashMap<String,String>();
		map.put("corpId", corpId);
		map.put("userId", user.getUserId());
		map.put("token", token);
		map.put("pageSize", pageSize);
		map.put("page", page);
		map.put("search", search);

		map.put("quesType", quesType);
		map.put("quespublish", quespublish);
		map.put("startDate", startDate);
		map.put("endDate", endDate);

		RestClient restClient = new RestClient();
		String configJson = restClient.get("/questionnaire/getQuesList", token, map);
		Map<String, Object> result = JsonUtils.readValue(configJson);
		List list = (List)result.get("data");
		Map<String,Object> resultMap = new HashMap<String,Object>();
		resultMap.put("data", list);
		resultMap.put("currentPage", Integer.parseInt(page));
		return OperationResultDing.buildSuccessResult(resultMap);
    }
    
    /**
     * 获取问卷列表
     * @param request
     * @return
     */
    @RequestMapping(value="/getDingMyQuesList", method=RequestMethod.GET, produces={"application/json; charset=UTF-8"})
    @ResponseBody
    public OperationResultDing getDingMyQuesList(HttpServletRequest request) {
		String type = request.getParameter("type");
		String page = request.getParameter("page");
		String pageSize = request.getParameter("pageSize");
		String search = request.getParameter("search");
		WebUser user = WebUtils.getCurrentUser();
		String corpId = user.getCorpId();
		String token = user.getJwtToken();
		//List<Map> page = questionnaireService.getQuesList(corpId,"",type);
		Map<String,String> map = new HashMap<String,String>();
		map.put("corpId", corpId);
		map.put("type", type);
		map.put("userId", user.getUserId());
		map.put("token", token);
		map.put("pageSize", pageSize);
		map.put("page", page);
		map.put("search", search);
		RestClient restClient = new RestClient();
		String configJson = restClient.get("/questionnaire/getQuesList", token, map);
		Map<String, Object> result = JsonUtils.readValue(configJson);
		List list = (List)result.get("data");
		Map<String,Object> resultMap = new HashMap<String,Object>();
		resultMap.put("data", list);
		resultMap.put("currentPage", Integer.parseInt(page));
		return OperationResultDing.buildSuccessResult(resultMap);
    }
    
    
    /**
     * 获取我的答卷列表
     * @param request
     * @return
     */
    @RequestMapping(value="/getDingMyAnswerList", method=RequestMethod.GET, produces={"application/json; charset=UTF-8"})
    @ResponseBody
    public OperationResultDing getDingMyAnswerList(HttpServletRequest request) {
    	String quesType = request.getParameter("quesType");
    	String page = request.getParameter("page");
    	String pageSize = request.getParameter("pageSize");
		String search = request.getParameter("search");
		String status = request.getParameter("status");
		String startDate = request.getParameter("startDate");
		String endDate = request.getParameter("endDate");
		WebUser user = WebUtils.getCurrentUser();
		String corpId = user.getCorpId();
		String token = user.getJwtToken();
		//List<Map> page = questionnaireService.getQuesList(corpId,"",type);
		Map<String,String> map = new HashMap<String,String>();
		map.put("corpId", corpId);
		map.put("userId", user.getUserId());
//		map.put("type", type);
		map.put("token", token);
		map.put("pageSize", pageSize);
		map.put("page", page);
		map.put("search", search);
		map.put("quesType", quesType);
		map.put("status", status);
		map.put("startDate", startDate);
		map.put("endDate", endDate);

		RestClient restClient = new RestClient();
		String configJson = restClient.get("/questionnaire/getAnswerList", token, map);
		Map<String, Object> result = JsonUtils.readValue(configJson);
		List list = (List)result.get("data");
		Map<String,Object> resultMap = new HashMap<String,Object>();
		resultMap.put("data", list);
		resultMap.put("currentPage", Integer.parseInt(page));
		return OperationResultDing.buildSuccessResult(resultMap);
    }
    
    /**
     * 获取成绩排名
     * @param request
     * @return
     */
    @RequestMapping(value="/getRankingList", method=RequestMethod.GET, produces={"application/json; charset=UTF-8"})
    @ResponseBody
    public OperationResultDing getRankingList(HttpServletRequest request) {
    	String quesId = request.getParameter("quesId");
    	String page = request.getParameter("page");
    	String pageSize = request.getParameter("pageSize");
		WebUser user = WebUtils.getCurrentUser();
		String corpId = user.getCorpId();
		String token = user.getJwtToken();
		Map<String,String> map = new HashMap<String,String>();
		map.put("corpId", corpId);
		map.put("token", token);
		map.put("quesId", quesId);
		map.put("pageSize", pageSize);
		map.put("page", page);

		RestClient restClient = new RestClient();
		String configJson = restClient.get("/questionnaire/getRankingList", token, map);
		Map<String, Object> result = JsonUtils.readValue(configJson);
		List list = (List)result.get("data");
		Map<String,Object> resultMap = new HashMap<String,Object>();
		resultMap.put("data", list);
		resultMap.put("currentPage", Integer.parseInt(page));
		return OperationResultDing.buildSuccessResult(resultMap);
    }
    
    /**
     * 获取问卷表单
     * @param request
     * @return
     */
    @RequestMapping(value="/getDingQuesForm", method=RequestMethod.GET, produces={"application/json; charset=UTF-8"})
    @ResponseBody
    public OperationResultDing getDingQuesForm(HttpServletRequest request) {
		WebUser user = WebUtils.getCurrentUser();
		String corpId = user.getCorpId();
		String token = user.getJwtToken();
		//List<Map> page = questionnaireService.getQuesList(corpId,"",type);
		Map<String,Object> map = new HashMap<String,Object>();
//		List<Map<String,Object>> list = dictDetailApiService.getDictDetailByCode("questionnaireType",corpId,token);
		//将枚举去除
		List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
		Map<String,Object> typeMap = new HashMap<String,Object>();
		typeMap.put("questionnaireVote", "投票");
		typeMap.put("questionnaireSurvey", "调查");
    	map.put("types", list);
		return OperationResultDing.buildSuccessResult(map);
    }
    
    /**
     * 保存问卷
     * @param entity
     * @param model
     * @return
     * @throws ParseException 
     */
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ResponseBody
    public OperationResultDing save(String entity, HttpServletRequest request) throws ParseException {
    	WebUser user = WebUtils.getCurrentUser();
    	String corpId = user.getCorpId();
		String token = user.getJwtToken();
		String orgId = user.getOrgId();
		String userId = user.getUserId();

		Map<String,String> map = new HashMap<String,String>();
		map.put("corpId", corpId);
		map.put("orgId", orgId);
		map.put("userId", userId);
		map.put("token", token);

    	RestClient restClient = new RestClient();
		String configJson = restClient.post("/questionnaire/save", token, map,entity);
		Map<String, Object> result = JsonUtils.readValue(configJson);
		if(result.get("type").toString().equals("success")){
			return OperationResultDing.buildSuccessResult("保存成功");
		}else{
			return OperationResultDing.buildFailureResult(result.get("message").toString());
		}
    	
    }
	
    /**
     * 获取问卷详情
     * @param request
     * @return
     */
    @RequestMapping(value="/getDingQuesInfo", method=RequestMethod.GET, produces={"application/json; charset=UTF-8"})
    @ResponseBody
    public OperationResultDing getDingQuesInfo(HttpServletRequest request) {
		String id = request.getParameter("id");
		String isAnwser = request.getParameter("isAnwser");
		String anUserId = request.getParameter("anUserId");
		WebUser user = WebUtils.getCurrentUser();
		String token = user.getJwtToken();
		//List<Map> page = questionnaireService.getQuesList(corpId,"",type);
		Map<String,String> map = new HashMap<String,String>();
		map.put("token", token);
		map.put("id", id);
		map.put("isAnwser", isAnwser);
		if(StringUtils.isNotBlank(anUserId)){
			map.put("userId", anUserId);
		}else{
			map.put("userId", user.getUserId());
		}
		map.put("corpId", user.getCorpId());
		RestClient restClient = new RestClient();
		String configJson = restClient.get("/questionnaire/getQuesInfo", token, map);
		Map<String, Object> result = JsonUtils.readValue(configJson);
		Map info = (Map)result.get("data");
		return OperationResultDing.buildSuccessResult(info);
    }
    
    /**
     * 保存答卷
     * @param entity
     * @return
     * @throws ParseException 
     */
    @RequestMapping(value = "/answerEdit", method = RequestMethod.POST)
    @ResponseBody
    public OperationResultDing answerEdit(String entity, HttpServletRequest request) throws ParseException {
    	WebUser user = WebUtils.getCurrentUser();
    	String corpId = user.getCorpId();
		String token = user.getJwtToken();
		String orgId = user.getOrgId();
		String userId = user.getUserId();
		
		String quesId = request.getParameter("quesId");
		String type = request.getParameter("type");
		String quesType = request.getParameter("quesType");
		String grade = request.getParameter("grade");
		String timingFlag = request.getParameter("timingFlag");
		Map<String,String> map = new HashMap<String,String>();
		map.put("corpId", corpId);
		map.put("orgId", orgId);
		map.put("userId", userId);
		map.put("orgId", orgId);
		map.put("quesId", quesId);
		map.put("type", type);
		map.put("quesType", quesType);
		map.put("grade", grade);
		map.put("timingFlag", timingFlag);
		map.put("token", token);
		
		/*ObjectMapper mapper = new ObjectMapper();
		String bodyDataParams;
		try {
			bodyDataParams = mapper.writeValueAsString(entity);
		} catch (JsonProcessingException e) {
			e.printStackTrace();
			return OperationResultDing.buildFailureResult("json转换失败");
		}*/
		
    	RestClient restClient = new RestClient();
		String configJson = restClient.post("/questionnaire/answerEdit", token, map,entity);
		Map<String, Object> result = JsonUtils.readValue(configJson);
		if(result.get("type").toString().equals("success")){
			return OperationResultDing.buildSuccessResult("保存成功");
		}else{
			return OperationResultDing.buildFailureResult(result.get("message").toString());
		}
    	
    }


	/**
	 * create by: gly<br>
	 * description:更新问卷状态<br>
	 * create time: 2019/1/9 14:50<br>
	 * @params:  
	 */
	@GetMapping("/updateQuesPublish")
    public OperationResultDing updateQuesPublish(HttpServletRequest request){
		//问卷id
		String quesId = request.getParameter("quesId");
		quesId = StringUtils.isNotBlank(quesId)?quesId:"";
		//问卷状态
		String publish = request.getParameter("publish");
		publish = StringUtils.isNotBlank(publish)?publish:"";
		WebUser user = WebUtils.getCurrentUser();
		Map<String,String> map = QuestionnaireUtils.getWebUserInfo2Map(user);
		map.put("quesId",quesId);
		map.put("publish",publish);
		RestClient restClient = new RestClient();
		String configJson = restClient.get("/questionnaire/updateQuesPublish", user.getJwtToken(), map);
		Map<String, Object> result = JsonUtils.readValue(configJson);
		return OperationResultDing.buildSuccessResult(result);
	}

	/**
	 * create by: gly<br>
	 * description:删除问卷<br>
	 * create time: 2019/1/9 16:05<br>
	 * @params:  
	 */
	@GetMapping("/deletQuesById")
	public OperationResultDing deletQuesById(HttpServletRequest request){
		//问卷id
		String quesId = request.getParameter("quesId");
		quesId = StringUtils.isNotBlank(quesId)?quesId:"";
		WebUser user = WebUtils.getCurrentUser();
		Map<String,String> map = QuestionnaireUtils.getWebUserInfo2Map(user);
		map.put("quesId",quesId);
		RestClient restClient = new RestClient();
		String configJson = restClient.get("/questionnaire/deletQuesById", user.getJwtToken(), map);
		Map<String, Object> result = JsonUtils.readValue(configJson);
		return OperationResultDing.buildSuccessResult(result);
	}

	/**
	 * 根据id查询问卷信息
	 * @param request
	 * @return
	 */
	@GetMapping("/getQuesInfoById")
	public OperationResultDing getQuesInfoById(HttpServletRequest request){
		String quesId = request.getParameter("quesId");
		quesId = StringUtils.isNotBlank(quesId)?quesId:"";
		WebUser user = WebUtils.getCurrentUser();
		Map<String,String> map = QuestionnaireUtils.getWebUserInfo2Map(user);
		map.put("quesId",quesId);
		map.put("type",request.getParameter("type"));
		RestClient restClient = new RestClient();
		String configJson = restClient.get("/questionnaire/getQuesInfoById", user.getJwtToken(), map);
		Map<String, Object> result = JsonUtils.readValue(configJson);
		return OperationResultDing.buildSuccessResult(result);
	}

	/**
	 * create by: gly<br>
	 * description:保存设计问卷<br>
	 * create time: 2019/1/10 17:19<br>
	 * @params:  
	 */
	@PostMapping("/saveDesign")
	public OperationResultDing saveDesign(String entity, HttpServletRequest request){
		WebUser user = WebUtils.getCurrentUser();
		String corpId = user.getCorpId();
		String token = user.getJwtToken();
		String orgId = user.getOrgId();
		String userId = user.getUserId();

		String quesId = request.getParameter("quesId");

		Map<String,String> map = new HashMap<String,String>();
		map.put("corpId", corpId);
		map.put("orgId", orgId);
		map.put("userId", userId);
		map.put("token", token);
		map.put("quesId", quesId);
		map.put("entity",entity);

		RestClient restClient = new RestClient();
		String configJson = restClient.post("/questionnaire/saveDesign", token, map,entity);
		Map<String, Object> result = JsonUtils.readValue(configJson);
		if(result.get("type").toString().equals("success")){
			return OperationResultDing.buildSuccessResult("保存成功");
		}else{
			return OperationResultDing.buildFailureResult(result.get("message").toString());
		}
	}
	
	/**
	 * create by: gly<br>
	 * description:手机发送提醒<br>
	 * create time: 2019/3/4 11:19<br>
	 * @params:  
	 */
	@PostMapping("/telSendMessage")
	public OperationResultDing telSendMessage(HttpServletRequest request){
		WebUser user = WebUtils.getCurrentUser();
		String corpId = user.getCorpId();
		String token = user.getJwtToken();
		String orgId = user.getOrgId();
		String userId = request.getParameter("userId");
		String quesId = request.getParameter("quesId");
		String isBatchSelect = request.getParameter("isBatchSelect");
		Map<String,String> map = new HashMap<String,String>();
		map.put("token", token);
		map.put("quesId", quesId);
		RestClient restClient = new RestClient();
		if ("true".equals(isBatchSelect)) {
			map.put("userName", "");
			map.put("departmentName", "");
			String userIdConfigJson = restClient.get("/questionnaire/getStatisticsNoAnswerInfo", user.getJwtToken(), map);
			Map<String, Object> userIdResult = JsonUtils.readValue(userIdConfigJson);
			List<String> userIdlist = (List<String>)userIdResult.get("data");
			userId = StringUtils.join(userIdlist, ",");
		}
		map.put("corpId", corpId);
		map.put("orgId", orgId);
		map.put("userId", userId);
		map.put("currentUserId", user.getUserId());
		//String configJson = restClient.post("/questionnaire/telSendMessage", token, map);
		String configJson = restClient.post("/questionnaire/telSendMessage", token, new HashMap<String, String>(), JsonUtils.writeValueAsString(map));
		Map<String, Object> result = JsonUtils.readValue(configJson);
		if(result.get("type").toString().equals("success")){
			return OperationResultDing.buildSuccessResult("提醒成功");
		}else{
			return OperationResultDing.buildFailureResult(result.get("message").toString());
		}
	}

	/**
	 * create by: gly<br>
	 * description:获取问卷题目<br>
	 * create time: 2019/1/11 14:52<br>
	 * @params:  
	 */
	@GetMapping("/getQuestTopic")
	public OperationResultDing getQuestTopic(HttpServletRequest request){

		String quesId = request.getParameter("quesId");
		WebUser user = WebUtils.getCurrentUser();
		Map<String,String> map = QuestionnaireUtils.getWebUserInfo2Map(user);
		map.put("quesId",quesId);
		RestClient restClient = new RestClient();
		String configJson = restClient.get("/questionnaire/getQuestTopic", user.getJwtToken(), map);
		Map<String, Object> result = JsonUtils.readValue(configJson);
		return OperationResultDing.buildSuccessResult(result);
	}

	/**
	 * create by: gly<br>
	 * description:获取登录用户姓名<br>
	 * create time: 2019/1/11 14:52<br>
	 * @params:
	 */
	@GetMapping("/getUserName")
	public OperationResultDing getUserName(HttpServletRequest request){
		WebUser user = WebUtils.getCurrentUser();
		return OperationResultDing.buildSuccessResult(user.getCnName());

	}


	/**
	 * create by: gly<br>
	 * description:获取统计列表<br>
	 * create time: 2019/1/24 9:55<br>
	 * @params:  
	 */
	@GetMapping("/getStatisticsList")
	public OperationResultDing getStatisticsList(HttpServletRequest request){
		String quesType = request.getParameter("quesType");
		String page = request.getParameter("page");
		String pageSize = request.getParameter("pageSize");
		String search = request.getParameter("search");
		String status = request.getParameter("status");
		String startDate = request.getParameter("startDate");
		String endDate = request.getParameter("endDate");
		WebUser user = WebUtils.getCurrentUser();
		Map<String,String> map = QuestionnaireUtils.getWebUserInfo2Map(user);
		map.put("pageSize", pageSize);
		map.put("page", page);
		map.put("search", search);
		map.put("quesType", quesType);
		map.put("status", status);
		map.put("startDate", startDate);
		map.put("endDate", endDate);
		RestClient restClient = new RestClient();
		String configJson = restClient.get("/questionnaire/getStatisticsList", user.getJwtToken(), map);
		Map<String, Object> result = JsonUtils.readValue(configJson);
		List list = (List)result.get("data");
		Map<String,Object> resultMap = new HashMap<String,Object>();
		resultMap.put("data", list);
		resultMap.put("currentPage", Integer.parseInt(page));
		return OperationResultDing.buildSuccessResult(resultMap);
	}


	/**
	 * create by: gly<br>
	 * description:获取提交人员列表<br>
	 * create time: 2019/1/24 16:12<br>
	 * @params:  
	 */
	@GetMapping("/getStatisticsPersonList")
	public OperationResultDing getStatisticsPersonList(HttpServletRequest request){

		WebUser user = WebUtils.getCurrentUser();
		Map<String,String> map = QuestionnaireUtils.getWebUserInfo2Map(user);
		String roles = user.getRoleCodes();
		if(roles.contains("appAdminRole")) {
			map.put("isAdmin", "1");
		}else {
			map.put("isAdmin", "0");
		}
		String quesId = request.getParameter("quesId");//问卷id
		String page = request.getParameter("page");
		String pageSize = request.getParameter("pageSize");
		String search = request.getParameter("search");
		String orgId = request.getParameter("orgId");
//		String startDate = request.getParameter("startDate");
//		String endDate = request.getParameter("endDate");
		map.put("quesId",quesId);
		map.put("pageSize", pageSize);
		map.put("page", page);
		map.put("search", search);
		map.put("orgId", orgId);
//		map.put("startDate", startDate);
//		map.put("endDate", endDate);
		RestClient restClient = new RestClient();
		String configJson = restClient.get("/questionnaire/getStatisticsPersonList", user.getJwtToken(), map);
		Map<String, Object> result = JsonUtils.readValue(configJson);
		List list = (List)result.get("data");
		Map<String,Object> resultMap = new HashMap<String,Object>();
		resultMap.put("data", list);
		resultMap.put("currentPage", Integer.parseInt(page));
		return OperationResultDing.buildSuccessResult(result);
	}
	
	/**
	 * create by: gly<br>
	 * description:获取未答人员列表<br>
	 * create time: 2019/1/24 16:12<br>
	 * @params:  
	 */
	@GetMapping("/getNoAnwserPersonList")
	public OperationResultDing getNoAnwserPersonList(HttpServletRequest request){

		WebUser user = WebUtils.getCurrentUser();
		Map<String,String> map = QuestionnaireUtils.getWebUserInfo2Map(user);
		String quesId = request.getParameter("quesId");//问卷id
		String page = request.getParameter("page");
		String pageSize = request.getParameter("pageSize");
		String search = request.getParameter("search");
		String orgId = request.getParameter("orgId");
		map.put("quesId",quesId);
		map.put("pageSize", pageSize);
		map.put("page", page);
		map.put("search", search);
		map.put("orgId", orgId);
		map.put("token", user.getJwtToken());
		RestClient restClient = new RestClient();
		String configJson = restClient.get("/questionnaire/getNoAnwserPersonList", user.getJwtToken(), map);
		Map<String, Object> result = JsonUtils.readValue(configJson);
		List list = (List)result.get("data");
		Map<String,Object> resultMap = new HashMap<String,Object>();
		resultMap.put("data", list);
		resultMap.put("currentPage", Integer.parseInt(page));
		return OperationResultDing.buildSuccessResult(resultMap);
	}


	/**
	 * create by: gly<br>
	 * description:<br>
	 * create time: 2019/1/25 10:05<br>
	 * @params:  
	 */
	@GetMapping("/quesBack")
	public OperationResultDing quesBack(HttpServletRequest request){
		String id = request.getParameter("id");
		String backReason = request.getParameter("backReason");
		WebUser user = WebUtils.getCurrentUser();
		Map<String,String> map = QuestionnaireUtils.getWebUserInfo2Map(user);
		map.put("id",id);
		map.put("backReason",backReason);
		RestClient restClient = new RestClient();
		String configJson = restClient.get("/questionnaire/quesBack", user.getJwtToken(), map);
		Map<String, Object> result = JsonUtils.readValue(configJson);
		return OperationResultDing.buildSuccessResult(result);
	}


	/**
	 * create by: gly<br>
	 * description:问卷统计<br>
	 * create time: 2019/1/25 13:50<br>
	 * @params:  
	 */
	@GetMapping("/getStatistics")
	public OperationResultDing getStatistics(HttpServletRequest request){
		String quesId = request.getParameter("quesId");
		WebUser user = WebUtils.getCurrentUser();
		Map<String,String> map = QuestionnaireUtils.getWebUserInfo2Map(user);
		map.put("quesId",quesId);
		RestClient restClient = new RestClient();
		String configJson = restClient.get("/questionnaire/getStatistics", user.getJwtToken(), map);
		Map<String, Object> result = JsonUtils.readValue(configJson);
		return OperationResultDing.buildSuccessResult(result);
	}


	/**
	 * create by: gly<br>
	 * description:特殊题型详情数据查询<br>
	 * create time: 2019/1/28 15:14<br>
	 * @params:  
	 */
	@GetMapping("/getOptionDetail")
	public OperationResultDing getOptionDetail(HttpServletRequest request){
		//题目id
		String topicId = request.getParameter("topicId");
		//问卷id
		String quesId = request.getParameter("quesId");
		//题型
		String topicType = request.getParameter("topicType");

		WebUser user = WebUtils.getCurrentUser();
		Map<String,String> paramMap = QuestionnaireUtils.getWebUserInfo2Map(user);

		paramMap.put("topicId",topicId);
		paramMap.put("quesId",quesId);
		paramMap.put("topicType",topicType);
		paramMap.put("token",user.getJwtToken());
		paramMap.put("corpId",user.getCorpId());
		RestClient restClient = new RestClient();
		String configJson = restClient.get("/questionnaire/getOptionDetail", user.getJwtToken(), paramMap);
		Map<String, Object> result = JsonUtils.readValue(configJson);
		return OperationResultDing.buildSuccessResult(result);
	}

}
